package com.lzm.ydpt.mvp.presenterimpl;

import com.byt.framlib.basemvp.BasePresenter;
import com.byt.framlib.basemvp.basebean.BaseResponseBean;
import com.byt.framlib.basemvp.exception.ApiException;
import com.byt.framlib.basemvp.listener.OnLoadingErrorListener;
import com.byt.framlib.basemvp.listener.OnLoadingProgressListener;
import com.google.gson.JsonObject;
import com.lzm.ydpt.module.mall.activity.MallFollowActivity;
import com.lzm.ydpt.mvp.api.ProgressSubscriber;
import com.lzm.ydpt.mvp.contract.MallFollowContract;
import com.lzm.ydpt.mvp.modelimpl.MallFollowModelImpl;

/**
 * 类名称：MallFollowPresenterImpl
 * 类描述：代理实现
 */
public class MallFollowPresenterImpl extends BasePresenter implements MallFollowContract.Presenter {

    private MallFollowContract.View mView;
    private MallFollowContract.Model mModel;

    public MallFollowPresenterImpl(MallFollowActivity context) {
        super(context);
        this.mView = context;
        this.mModel = new MallFollowModelImpl();
    }

    @Override
    public void onMallFollow() {
        mManager.http(mModel.onMallFollow(), getLifecycleProvider(), new ProgressSubscriber<>(mContext, new OnLoadingProgressListener<JsonObject>() {
            @Override
            public void onLoadingResult(BaseResponseBean<JsonObject> entity) {
                mView.onMallFollow();
            }
        }, new OnLoadingErrorListener() {
            @Override
            public void onError(ApiException e, String method) {
                mView.showMessage(e.getDisplayMessage(), method);
            }

            @Override
            public void onErrorResult(BaseResponseBean entity, String method) {
                mView.showMessage(entity.getMessage(), method);
            }
        }, "onMallFollow"));
    }
}